//
//  MRMRootViewController.m
//  MeiRiMoney
//
//  Created by qiuqk on 13-6-7.
//  Copyright (c) 2013年 MeiRiCai. All rights reserved.
//

#import <QuartzCore/QuartzCore.h>
#import "MRMRootViewController.h"
#import "YouMiWall.h"
#import "UIDevice+IdentifierAddition.h"
#import "OAuthConsumer.h"
#import "MRMSdk.h"
#import "MRMUtils.h"
#import "MRMWallsViewController.h"
#import "DianJoyLandingPageView.h"
#import "MRMDianJoyAdWallDetegateInstance.h"
#import "MRMControllerManager.h"
#import "MRMSettingDelegateImpl.h"

@interface MRMRootViewController ()
{
	IASKAppSettingsViewController *appSettingsViewController;
	MRMSettingDelegateImpl *settingDelegateImpl;
}

@end

@implementation MRMRootViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
	// Do any additional setup after loading the view.
	UIImage *bgBarImage = [UIImage imageNamed:@"light-menu-bar.png"];
	[self.navigationController.navigationBar setBackgroundImage:bgBarImage forBarMetrics:UIBarMetricsDefault];
	[MRMUtils setTopBarTitle:self title:self.navigationItem.title];
	[MRMUtils setSettingButton:self];
	
	LoginResult *loginResult = [MRMSdk login];
	if (loginResult != nil)
	{
		self.integralLabel.text = [MR_Convert longToString:loginResult.IntegralBalance];
	}
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - 视图事件

- (void) showSettingView
{
	IASKAppSettingsViewController *controller = [MRMControllerManager AppSettingsViewController];
	settingDelegateImpl = [[MRMSettingDelegateImpl alloc] init];
	controller.delegate = settingDelegateImpl;
	controller.showDoneButton = NO;
	[MRMUtils setBackButton:controller];
	[MRMUtils setTopBarTitle:controller title:@"设置"];
	[self.navigationController pushViewController:controller animated:YES];
}

- (IBAction)refreshIntegral:(id)sender
{
	int i = [MRMSdk getIntegralBalance];
	if(i != 0)
	{
		self.integralLabel.text = [NSString stringWithFormat:@"%i", i];
	}
}

- (IBAction)showWallTasks:(id)sender
{
	UIViewController *viewController;
	viewController = [[MRMWallsViewController alloc] initWithNibName:@"MRMWallsViewController" bundle:nil];
	viewController.title = @"任务列表";
	
	[self.navigationController pushViewController:viewController animated:YES];
}

- (void)viewDidUnload {
	[self setMobileButton:nil];
	[self setAlipayButton:nil];
	[self setWallTaskButton:nil];
	[super viewDidUnload];
}
@end
